This invention relates to a method and apparatus for displaying a ladder diagram. More particularly, the invention relates to a method and apparatus well-suited for displaying ladder diagrams indicative of sequence control performed by a programmable sequence controller.
Numerical control systems permit various mechanical elements in machine tools to be controlled on the basis of commands issued by a numerical control device which incorporates an operator's panel. In such numerical control systems a hardwired switch network or so-called "magnetics" unit comprising a multiplicity of relays is connected between the numerical control device, commonly referred to as an NC device, and the machine tool. Prescribed ones of these relays are actuated in response to the commands issued by the NC device, whereby the prescribed elements of the machine tool are caused to operate in the manner specified by the commands. These commands may be entered directly from the operator's panel, or may be generated in response to programmed M-function and S-function instructions. Disadvantages encountered in the conventional systems of the above type are the large size of the apparatus and the high cost entailed by the large number of relays, as well as poor reliability attributed to mechanical failure of the relays.
In view of the foregoing disadvantages, sequence controllers, also known as programmable sequence controllers, are now the most widely used means for performing, through program processing, the function of the magnetics unit A programmable sequence controller (referred to hereinafter as a PSC) according to the prior art is illustrated in FIG. 1. A numerical control device 1 is separate from the conventional PSC 2 installed in a machine tool. The numerical control device 1 includes a paper tape 101a bearing machining commands in punched form, a paper tape reader 101a' for reading the paper tape, a random access memory (RAM) 101b for storing the machining commands read in from the paper tape 101a, a read-only memory (ROM) 101c storing a control program for controlling the numerical control device 1, a central processing unit (CPU) 101d for executing processing in accordance with a machining command program or a control program, a transceiver unit 101e, such as a direct memory access controller (DMAC), for the purpose of sending data to and receiving data from the sequence controller 2, and an arithmetic circuit 101f comprising a so-called pulse distributing circuit which receives as inputs thereto signals indicative of amounts of movement X.sub.o, Y.sub.o along the X and Y axes, respectively, and a signal indicative of feed speed F, for producing distributed pulses X.sub.p, Y.sub.p by performing a well-known arithmetic pulse distribution operation based on these signal inputs. The numerical control device 1 also includes a manual data input unit (MDI) l0lh that is mounted on the operator's panel of the numerical control device 1 for entering single blocks of machining command data when, say, adding to or modifying such data. Also provided is a universal display unit 101i for displaying, e.g., the present position of a tool or the like Note that the display unit 101i and MDI 101h may be constructed as a single unit. The above-mentioned units are interconnected by a bus line 101g.
The PSC 2 comprises a programmer 201 for converting an entered sequence program into machine language and for correcting the sequence program, and a sequence controller cabinet 202. The programmer 201 includes a paper tape 201a bearing a correspondence table (described below) and a sequence program in punched form, a paper tape reader 201b for reading the paper tape 201a, and a random access memory (RAM) 201c for storing the sequence program. A sequence program performs the function of a magnetics unit, expressing the function thereof in logical form using operation codes and operands which make up a program. By way of example, a ladder diagram for part of the magnetics unit shown in FIG. 2 may be programmed as depicted in FIG. 3. In FIG. 3, the operation codes in the sequence program are given by RD, AND, WRT, OR, AND NOT and so on. RD is a read operation instruction, AND a logical product instruction, WRT a write operation instruction, OR a logical sum instruction, and AND NOT an instruction for logical multiplication with a negated value. Further, MF, M28, . . . , AUT, MO3 . . . represent the operands of the sequence program and correspond to prescribed addresses and prescribed bits in a data memory 202a, described below, located within the sequence controller cabinet 202 The PSC 2, based on the group of instructions (1) shown in FIG. 3, executes the following logical operation:
MF M28 M24 M22 M21 M18 M14 M12 M11
and stores the result of the operation (either logical "1" or logical "0") in the data memory 202a at the prescribed bit of the prescribed address corresponding to operand MO3. The PSC 2 also executes the following logical operation based on the group of instructions (2):
AUT MO3 SPCCW
and stores the result of the operation ("1" or "0") in the data memory 202a at the prescribed bit of the prescribed address designated by the operand SPCW
Returning to FIG. 1, the programmer 201 further includes a correspondence table 201d for storing the corresponding relationships between the symbols MF, AUT . . . constituting the operands of the sequence program, and storage locations of the data memory 202a. An example of what is stored in the correspondence table is illustrated in FIG. 4. It will be seen that the symbol AUT corresponds to the first bit of the tenth address of the data memory 10, that symbol MO3 corresponds to the second bit of the tenth address, and likewise through symbol CRA, which corresponds to the second bit of the 42nd address. The ladder diagram of FIG. 2 also shows the symbols matched with the corresponding storage locations. The programmer 201 is also provided with a read-only memory (ROM) 201e for storing, e.g., a control program for controlling the overall programmer 201, as well as a language translator program for translating the sequence program read in from the paper tape 201a into machine language. The programmer 201 further comprises a central processing unit (CPU) 201f for executing, e.g., translation and correction of the sequence program in accordance with the program stored in the ROM 201e, and a transceiving unit 201g having a buffer or the like for sending data to and receiving data from the sequence controller cabinet 202. The foregoing units constituting the programmer 201 are interconnected by a bus line 201h.
The sequence controller cabinet 202 includes the data memory 202a mentioned above. The data memory 202a establishes correspondence between each relay of the magnetics unit shown in FIG. 2 and a single bit, the on/off (closed/open) state of a relay being represented by logical "1" or logical "0", respectively, in the corresponding bit. For example, assume that the operator places the system in the automatic mode using the operator's panel. With a magnetics unit, the relay AUT in the power sequence circuit would be placed in the ON state. With the PSC, however, logical "1" is stored in the first bit of the tenth address in data memory 202a. The sequence controller cabinet 202 also includes a transceiving unit 202b having a buffer or the like for supervising the transmission and reception of data with the programmer 201, a RAM 202c for storing the sequence program translated into machine language by the programmer 201, a data input/output unit 202d for supervising the transmission and reception of data with the machine tool 3, a ROM 202e for storing the control program which controls the overall sequence controller cabinet 202, a central processing unit 202f for executing prescribed sequence processing in accordance with the control program and sequence program, and a transceiving unit 202g for sending data to and receiving data from the numerical control device 1. The units constituting the sequence controller cabinet 202 are interconnected by a bus line 202h.
FIG. 5 is a block diagram showing the data input/output unit 202d in greater detail. The data input/output unit 202d comprises a data input circuit DI and a data output circuit DO. The data input circuit DI includes receivers R.sub.1 through R.sub.n which receive signals from various limit switches and relay contacts RC.sub.1 through RC.sub.n delivered from the machine side on cables l.sub.11 through l.sub.1n, AND gates G.sub.1 through G.sub.n receiving the outputs of the respective receivers R.sub.1 through R.sub.n, and a decoder DEC.sub.1 which decodes address signals received from an address bus ABUS to open predetermined ones of the AND gates, the AND gate output being sent out on the data bus DBUS. The data output circuit DO includes flip-flops (or latch circuits if desired) L.sub.1 through L.sub.m for storing such signals as forward and reverse spindle rotation signals obtained from the machine tool 3, drivers D.sub.1 through D.sub.m provided for corresponding ones of the flip-flops (flip-flop will be abbreviated FF hereinafter) L.sub.1 through L.sub.m for delivering the output signals from the FFs to the machine tool 3 via cables l.sub.21 through l.sub.2m to actuate the relays Ry.sub.1 through Ry.sub.m, and a decoder DEC.sub.2 which decodes address signals received from the address bus ABUS to place predetermined ones of the FFs in a settable or resettable state, and which stores in predetermined FFs the data received from the data bus DBUS. In addition to the buses ABUS and DBUS, a control signal bus CBUS is provided for sending and receiving control signals. The above-mentioned cables l.sub.11 through l.sub.1n and l.sub.21 through l.sub.2m interconnect the data input/output unit 202d and the machine tool so that data may be sent and received between them.
The PSC 2 operates in the following manner. First, a table showing the correspondence between symbols and storage locations is prepared while referring to the ladder diagram (FIG. 2) of the magnetics circuit, and the table is punched in a paper tape. A sequence program also is prepared in the above-described manner using operation codes and symbols (operands) and is similarly punched into the paper tape 201a. Next, the punched tape 201a is read by the paper tape reader 201b to store the correspondence table in table 201d and the sequence program in the RAM 201c. When the foregoing has been accomplished the PSC 2 starts executing the language processing program stored in the ROM 201e, reads the instructions in the sequence program out of the RAM 201c in successive fashion and converts the operation codes and operands into machine language. The PSC uses the correspondence table to convert each operand into the machine word representing the prescribed address and bit of the data memory 202a. The sequence program converted into these machine words is transferred to and stored in the RAM 202c through the transceiver unit 201g of the programmer 201 and the transceiver unit 202b of the sequence controller cabinet 202. The programmable sequence controller 2 is now capable of executing sequence processing. Henceforth, in accordance with the control program, the CPU 202f reads the sequence program instructions successively out of the RAM 202c one instruction at a time, executes sequence processing from the first to the last instructions of the sequence program and then returns to the first instruction to repeat the cycle. Thus the PSC 2 steps through the sequence program in a repetitive fashion.
Now assume that a command such as the command MO3 for forward spindle rotation is issued by the numerical control device 101. When this takes place, with reference to FIG. 4, logical "1" is written into the data memory 202a in the first bit of the 66th address where the M-function is to be stored, in the first bit of the 67th address where the M-code signal Mll is to be stored, and in the second bit of the 67th address where the M-code signal M12 is to be stored.
Since the central processing unit 202f is executing sequence processing by repeatedly stepping through the sequence program cyclically and reading out the instructions thereof in consecutive fashion, logical "1" will be stored in the fifth bit of the 20th address of data memory 202a when the groups of instructions (1) and (2) in the sequence program (FIG. 3) have been executed. Thereafter, the status (SPCW="1") of the fifth bit at the 20th address is stored in, say, FF L.sub.1 of the data output circuit DO (FIG. 5) and delivered to the machine tool 3 through the driver D.sub.1 and cable l.sub.21. This item of data places the relay R.sub.1 of the machine tool 3 in the ON state so that the spindle of the machine tool is rotated in the forward direction. Now assume that, say, the relay contact RCI on the machine tool side closes (i.e., assumes the ON state) during forward rotation of the spindle, thereby indicating completion of the rotation operation. As a result, a forward rotation end signal (logical "1") from the machine tool side, which signal is produced by closure of the relay contact RC.sub.1, is stored in a prescribed bit of the data memory 202a (FIG. 1) through the cable l.sub.11, receiver R.sub.1, AND gate G and data bus DBUS. Sequence programming then continues and the numerical control device 1 is informed of completion of the forward rotation operation. This ends the sequence step for forward rotation of the spindle.
In the case described above the PSC 2 is provided with the programmer 201. An arrangement as shown in FIG. 6 is possible, however, in which the programmer 201 and transceiver unit 202b are deleted, a sequence program already converted into machine language is read in from the numerical control device 1 by reading means (such as the paper tape reader 101a') and is stored in the RAM 202c through the transceiver units 101e and 202g. In place of the RAM 202c, moreover, it is possible to use a ROM for storing a sequence program comprising machine language. Furthermore, while the numerical control device 1 and PSC 2 are shown as provided separately in FIGS. 1 and 6, these can be integrated into a single unit and share the same processor, as illustrated in FIG. 7. In FIG. 7, portions similar to those shown in FIG. 1 are designated by like reference characters. Numeral 101k denotes the above-mentioned ROM for storing the sequence program expressed in machine language.
The numerical control system having the construction shown in FIGS. 1, 6 and 7 is capable of displaying a ladder diagram on the universal display unit 101i in order to facilitate sequence program debugging and maintenance processing. When displaying a ladder diagram in accordance with the prior-art method, however, the diagram segments or "rungs" are displayed sequentially in the order in which the sequence program is written. Accordingly, in order to investigate why, say, a control relay or output relay does turn on (i.e., close) when checking sequence logic during debugging or when a failure has occurred, the first task the operator must undertake is to find the pertinent control relay or output relay in the ladder diagram, which generally is many pages long. The operator must then investigate the conditions under which the relay turns on. The latter step, however, similarly entails searching the ladder diagram for the relays involved in turning the above-mentioned relay on, where the ladder diagram covers a large number of pages as stated above. In other words, debugging or maintenance cannot be carried out with facility in accordance with the prior-art method, where the sequence program is displayed in accordance with the order in which it was originally written.